﻿@{
    ViewBag.Title = "ClockUpdate";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<h2>Clock Update</h2>


<div ng-app>
    <div ng-controller="MyController">
        <label>Current Time: {{ clock.now }}</label>
    </div>
</div>

<script type="text/javascript">
    function MyController($scope) {
        $scope.clock = {
            now: new Date().format("yyyy-MM-dd hh:mm:ss")
        };

        var updateClock = function () {
            $scope.clock.now = new Date().format("yyyy-MM-dd hh:mm:ss")
        };

        setInterval(function () {
            $scope.$apply(updateClock);
        }, 1000);

        updateClock();
    };
</script>
